package com.elai.operate.controller;

import java.util.List;

import com.elai.common.annotation.Log;
import com.elai.common.core.controller.BaseController;
import com.elai.common.core.domain.AjaxResult;
import com.elai.common.core.page.TableDataInfo;
import com.elai.common.enums.BusinessType;
import com.elai.common.utils.poi.ExcelUtil;
import com.elai.operate.domain.OperatePalnDO;
import com.elai.operate.service.OperatePalnService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 运营计划Controller
 *
 * @author elai
 * @date 2021-03-23
 */
@RestController
@RequestMapping("/operate/plan")
public class OperatePalnController extends BaseController
{
    @Autowired
    private OperatePalnService operatePalnService;

    /**
     * 查询运营计划列表
     */
    @GetMapping("/list")
    public TableDataInfo list(OperatePalnDO operatePaln)
    {
        startPage();
        List<OperatePalnDO> list = operatePalnService.selectOperatePalnList(operatePaln);
        return getDataTable(list);
    }

    /**
     * 导出运营计划列表
     */
    @PreAuthorize("@ss.hasPermi('operate:plan:export')")
    @Log(title = "运营计划", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OperatePalnDO operatePaln)
    {
        List<OperatePalnDO> list = operatePalnService.selectOperatePalnList(operatePaln);
        ExcelUtil<OperatePalnDO> util = new ExcelUtil<OperatePalnDO>(OperatePalnDO.class);
        return util.exportExcel(list, "plan");
    }

    /**
     * 获取运营计划详细信息
     */
    @PreAuthorize("@ss.hasPermi('operate:plan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(operatePalnService.selectOperatePalnById(id));
    }

    /**
     * 新增运营计划
     */
    @PreAuthorize("@ss.hasPermi('operate:plan:add')")
    @Log(title = "运营计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OperatePalnDO operatePaln)
    {
        return toAjax(operatePalnService.insertOperatePaln(operatePaln));
    }

    /**
     * 修改运营计划
     */
    @PreAuthorize("@ss.hasPermi('operate:plan:edit')")
    @Log(title = "运营计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OperatePalnDO operatePaln)
    {
        return toAjax(operatePalnService.updateOperatePaln(operatePaln));
    }

    /**
     * 删除运营计划
     */
    @PreAuthorize("@ss.hasPermi('operate:plan:remove')")
    @Log(title = "运营计划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(operatePalnService.deleteOperatePalnByIds(ids));
    }

    /**
     * 获取用户圈人标签
     */
    @Log(title = "获取用户圈人标签", businessType = BusinessType.OTHER)
    @GetMapping("/getSelectTags")
    public AjaxResult getSelectTags()
    {
       List list= operatePalnService.getOperateSelectTages();
       return AjaxResult.success(list);
    }
}
